using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CollegeShop.Infrastructure.Entities.Repository;

namespace CollegeShop.Infrastructure.Entities.Entity
{
    public class Deliveryaddress : IAccessible<T_Deliveryaddress, Deliveryaddress>, ILogicEntity<T_Deliveryaddress, Deliveryaddress>
    {
        public int ID { get; set; }

        public string UserName { get; set; }

        public int SalesUnitID { get; set; }

        public bool isDefault { get; set; }

        public string Address { get; set; }

        public string LinkMan { get; set; }

        public string LinkPhone { get; set; }

        #region extend
        public Salesunit saleUnit { get; set; }
        #endregion

        protected override void Covariant(T_Deliveryaddress model)
        {
            if (model != null)
            {
                this.ID = model.ID;
                this.UserName = model.UserName;
                this.Address = model.Address;
                this.LinkMan = model.LinkMan;
                this.LinkPhone = model.LinkPhone;
                this.isDefault = model.isDefault;
                this.SalesUnitID = model.SalesUnitID;
            }
        }

        protected override T_Deliveryaddress Inverter(Deliveryaddress model)
        {
            if (model != null)
            {
                return new T_Deliveryaddress()
                {
                    ID = model.ID,
                    UserName = model.UserName,
                    SalesUnitID = model.SalesUnitID,
                    Address = model.Address,
                    LinkMan = model.LinkMan,
                    LinkPhone = model.LinkPhone,
                    isDefault = model.isDefault,
                };
            }
            return null;
        }
        public Deliveryaddress Set(T_Deliveryaddress dbModel)
        {
            Covariant(dbModel);
            return this;
        }

        public Deliveryaddress LoadSaleUnit(T_Salesunit model)
        {
            this.saleUnit = new Salesunit().Set(model);
            return this;
        }
    }
}
